package org.fault.service;


import org.fault.entity.ParamEntity;
import org.fault.strategy.IHaitongHandleStrategy;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class HaitongSerivceImpl implements  IHaitongSerivce{

    private Map<Integer, IHaitongHandleStrategy> strategyMap = new ConcurrentHashMap<>();

    public HaitongSerivceImpl( List<IHaitongHandleStrategy> list){
        for(IHaitongHandleStrategy strategy :list){
            strategyMap.put(strategy.getType(),strategy);
        }

    }
    @Override
    public Object trans(ParamEntity paramEntity) {


        Integer type = paramEntity.getType();
        IHaitongHandleStrategy strategy = strategyMap.get(type);
        String handle = strategy.handle(paramEntity);

        return handle;
    }
}
